<?php

namespace apiend\modules\course\controllers;

use Yii;
use apiend\components\Controller;
use apiend\modules\course\models\CourseApplyForm;

/**
 * 用户发布活动接口
 * Apply controller for the `course` module
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class ApplyController extends Controller {

    /**
     * @inheritdoc
     */
    protected function rules() {
        return [
            [
                'allow' => true,
                'roles' => ['@'],
            ],
        ];
    }

    /**
     * @inheritdoc
     */
    protected function verbs() {
        return [
            '*' => ['POST'],
        ];
    }

    /**
     * actionUpdate
     *
     * @view create.php
     * @return mixed
     */
    public function actionCreate() {
        $model = new CourseApplyForm();
        if (!$model->load(Yii::$app->request->post(), '')) {
            return $model->dumpError('发布失败，请检查参数的有效性');
        }
        $model->user_id = $this->token->user_id;
        return $model->save();
    }

}
